package com.tuliyou.dto;

import com.tuliyou.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

// UserDTO.java
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDTO {
    private Long id;
    private String username;
    private String email;
    private String phone;
    private String userType;
    private String province;
    private String examType;
    private Integer examScore;
    private Integer provinceRank;
    private LocalDateTime createdAt;

    public static UserDTO fromUser(User user) {
        if (user == null) return null;

        return new UserDTO(
                user.getId(),
                user.getUsername(),
                user.getEmail(),
                user.getPhone(),
                user.getUserType(),
                user.getProvince(),
                user.getExamType(),
                user.getExamScore(),
                user.getProvinceRank(),
                user.getCreatedAt()
        );
    }
}
